package com.ygxsk.carhome.ui.archive;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.flyco.roundview.RoundTextView;
import com.gyf.immersionbar.ImmersionBar;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.hjq.toast.Toaster;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.yanzhenjie.permission.AndPermission;
import com.yanzhenjie.permission.runtime.Permission;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.alertview.AlertView;
import com.ygxsk.carhome.alertview.OnItemClickListener;
import com.ygxsk.carhome.configeng.GifSizeFilter;
import com.ygxsk.carhome.configeng.Glide4Engine;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.enumwrap.ArchiveUpdateType;
import com.ygxsk.carhome.event.EventArchiveDetail;
import com.ygxsk.carhome.listener.AuthorityCallbackListener;
import com.ygxsk.carhome.listener.DoSomeThingListener;
import com.ygxsk.carhome.listener.ErrorParentExtraSingle;
import com.ygxsk.carhome.permission.PermissionSetting;
import com.ygxsk.carhome.permission.RuntimeRationale;
import com.ygxsk.carhome.response.ArchivesManageFileMy;
import com.ygxsk.carhome.response.ArchivesManageImage;
import com.ygxsk.carhome.response.FileSingleUpLoadBean;
import com.ygxsk.carhome.response.FileUpLoad;
import com.ygxsk.carhome.response.InformationAccessoryUpLoad;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.sys.PermissionNameConvert;
import com.ygxsk.carhome.ui.ErrorActivity;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.integrated.retrofit.Parameterkey;
import com.zhongjh.albumcamerarecorder.album.filter.BaseFilter;
import com.zhongjh.albumcamerarecorder.preview.BasePreviewActivity;
import com.zhongjh.albumcamerarecorder.settings.AlbumSetting;
import com.zhongjh.albumcamerarecorder.settings.CameraSetting;
import com.zhongjh.albumcamerarecorder.settings.GlobalSetting;
import com.zhongjh.albumcamerarecorder.settings.MultiMediaSetting;
import com.zhongjh.common.entity.LocalFile;
import com.zhongjh.common.entity.MultiMedia;
import com.zhongjh.common.entity.SaveStrategy;
import com.zhongjh.common.enums.MimeType;
import com.zhongjh.progresslibrary.entity.MultiMediaView;
import com.zhongjh.progresslibrary.listener.MaskProgressLayoutListener;
import com.zhongjh.progresslibrary.widget.MaskProgressLayout;

import org.greenrobot.eventbus.EventBus;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.BiFunction;
import io.reactivex.rxjava3.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-08-28  21:38
 * @Description: 是档案附件整个编辑的变种。是单个编辑 例如【身份证、发票、三包凭证等 单个的标记】
 */
public class ArchiveImageFileTypeActivity extends ErrorActivity implements ErrorParentExtraSingle {

    protected static final int REQUEST_CODE_CHOOSE = 2361;

    @BindView(R.id.layoutbuttonarchivefileedit)
    RoundTextView layoutButtonArchiveFileEdit;

    @BindView(R.id.mplimagelistinarchivefileedit)
    MaskProgressLayout mplimageListInArchiveFileEdit;

    //做上传图片的记录,当前正在要做修改的
    private ArrayList<HashMap<String, Object>> fileSingleUpLoadFiles_upLoad_hashMap = new ArrayList<>();

    //剩余的另一半的附件的逻辑：是排除掉当前正在修改的 这个类型附件的剩余的历史记录。

    private ArrayList<HashMap<String, Object>> fileSingleUpLoadFiles_upLoad_hashMap_history = new ArrayList<>();

    //添加该页面的设置内容；
    private GlobalSetting mGlobalSetting;

    //携带当前编辑的附件的类型
    private int extra_archivesManageFileType;

    //携带的 从列表过来的这条数据
    private InformationManageVoExtra extra_InformationManageVo_extra;
    //携带 动态附件的逻辑的实体，主要是图片和附件类型
    private ArchivesManageFileMy extra_ArchivesManageFileMy;
    //档案附件的地址链接
//    private ArrayList<InformationAccessoryUpLoad> extra_informationAccessoryList = new ArrayList<>();

    //携带的单纯的图片信息,这里是要改造的2024-2-26 11:14:46 是单独这一类的附件信息
    private ArrayList<String> extra_accessorysForAppUrlList = new ArrayList<>();

    //添加这条档案的id信息；
    private String vehicleId_informationId_upLoad = "";


    @OnClick({R.id.layoutbuttonarchivefileedit})//车辆类型是新车或者是二手车
    public void onViewClickedInArchiveImage(View v) {

        switch (v.getId()) {

            case R.id.layoutbuttonarchivefileedit: {

                //验证图片的集合是否为空
                //勿删：如下json是从提交档案的 大大表单 的提交 粘贴过来的。
                method_test_upLoadHashMapCurentChange();
                //勿删：原始的记录的
                method_test_upLoadHashMap_history();

                //------------------------------------------------------------------------------------------------------------------------------
                //底部档案的总的附件
                ArrayList<InformationAccessoryUpLoad> informationAccessoryList_UpLoad = new ArrayList<InformationAccessoryUpLoad>();

                //------------------------------------------------------------------------------------------------------------------------------

                method_fill_hashMap_for_upLoad(fileSingleUpLoadFiles_upLoad_hashMap, informationAccessoryList_UpLoad);

                //------------------------------------------------------------------------------------------------------------------------------
                //给历史记录的再添加进来
                method_fill_hashMap_for_upLoad(fileSingleUpLoadFiles_upLoad_hashMap_history, informationAccessoryList_UpLoad);

                //------------------------------------------------------------------------------------------------------------------------------

                //如果档案附件是空，也给提示-因为必传
                if (informationAccessoryList_UpLoad != null && informationAccessoryList_UpLoad.isEmpty()) {

                    CommUtils.checkDialog(mAlertView);

                    String messageBefore = getResources().getString(R.string.please_archive_choose_half);
                    String messageResult = "";
                    if (extra_ArchivesManageFileMy != null) {
                        messageResult = messageBefore + extra_ArchivesManageFileMy.getFileTypeName();
                    } else {
                        messageResult = getResources().getString(R.string.please_archive_choose);
                    }

                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, messageResult, true);
                    mAlertView.show();

                    return;
                }


                //直接添加上传信息
                CommUtils.checkDialog(mAlertView);
                mAlertView = new AlertView(StringUtils.getString(R.string.clearaddorsubmitsuretitletips), //提示
                        StringUtils.getString(R.string.clearaddorsubmitsuremessage),//提示内容
                        StringUtils.getString(R.string.clearcachecancel), //取消
                        new String[]{StringUtils.getString(R.string.clearaddorsubmitsure)},//确定
                        null, mActivityInstance, AlertView.Style.Alert, new OnItemClickListener() {//
                    @Override
                    public void onItemClick(Object o, int position) {

                        if (position != AlertView.CANCELPOSITION) {

                            method_remedialItems_addSubmit_upLoad(informationAccessoryList_UpLoad);

                        }
                    }
                });

                mAlertView.setCancelable(true);
                mAlertView.show();

                break;
            }

            default:
                break;
        }

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mActivityInstance = this;

        if (fileSingleUpLoadFiles_upLoad_hashMap == null) {
            fileSingleUpLoadFiles_upLoad_hashMap = new ArrayList<>();
        }

        initConfig();

        processExtraData();

        initViews();


    }

    private void initConfig() {

        // 拍摄有关设置
        CameraSetting cameraSetting = new CameraSetting();
        // 支持的类型：图片，视频
        cameraSetting.mimeTypeSet(MimeType.ofImage());
        // 相册
        AlbumSetting albumSetting = new AlbumSetting(true);
        albumSetting.mimeTypeSet(MimeType.ofImage());
        albumSetting.showSingleMediaType(true);
        albumSetting.countable(true);
        albumSetting.addFilter(new GifSizeFilter(320, 320, 5 * BaseFilter.K * BaseFilter.K));
        albumSetting.gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size));
        albumSetting.thumbnailScale(0.85f);
        albumSetting.setOnSelectedListener(localFiles -> {
            // 每次选择的事件
//                    LogUtils.d("itchen---onSelected", "onSelected: localFiles.size()=" + localFiles.size());
        });
        albumSetting.originalEnable(true);
        albumSetting.maxOriginalSize(Parameterkey.maxOriginalSize_one);
        albumSetting.setOnCheckedListener(isChecked -> {
            // 是否勾选了原图
//                    LogUtils.d("itchen----isChecked", "onCheck: isChecked=" + isChecked);
        });// 支持的类型：图片，视频
// 仅仅显示一个多媒体类型
// 是否显示多选图片的数字
// 自定义过滤器
// 九宫格大小
// 图片缩放比例
// 开启原图
// 最大原图size,仅当originalEnable为true的时候才有效
// 录音机
//        RecorderSetting recorderSetting = new RecorderSetting();

        // 全局
        mGlobalSetting = MultiMediaSetting.from(ArchiveImageFileTypeActivity.this)
                .choose(MimeType.ofImage())
                .albumSetting(albumSetting)
                .cameraSetting(cameraSetting)
                .isImageEdit(false)//
//                .recorderSetting(recorderSetting)
                // 设置路径和7.0保护路径等等 com.ygxsk.carhome.fileprovider
                .allStrategy(new SaveStrategy(true, ConstantSign.FILE_PROVIDER, ConstantSign.FILE_PROVIDER_AA_TEST))//"AA/test"
                // 如果设置这个，有关图片的优先权比allStrategy高
                .pictureStrategy(new SaveStrategy(true, ConstantSign.FILE_PROVIDER, ConstantSign.FILE_PROVIDER_AA_PICTURE))//AA/picture
                // 如果设置这个，有关音频的优先权比allStrategy高
                //.audioStrategy(new SaveStrategy(true, "com.ygxsk.integrated.fileprovider", "AA/audio"))
                // 如果设置这个，有关视频的优先权比allStrategy高
                .videoStrategy(new SaveStrategy(true, ConstantSign.FILE_PROVIDER, ConstantSign.FILE_PROVIDER_AA_VIDEO))//"AA/video"
                //  .imageEngine(new GlideEngine())  // for glide-V3     // for glide-V4
                .imageEngine(new Glide4Engine());

    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_archive_images;
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();

        ImmersionBar.with(this)//
                .titleBar(R.id.toolbarygxskout)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                //.statusBarColor(R.color.colorPrimary)//
                //.navigationBarColor(R.color.colorPrimary)//
                //.keyboardEnable(true)
                .init();
    }


    @Override
    protected void initToolBar(ToolbarHelper toolbarHelper) {

        toolbarHelper.setTitle(getString(R.string.title_archive_issue));
        toolbarHelper.setVersionName(true, AppUtils.getAppVersionName());
        toolbarHelper.setLayoutClose(false, "", null);
        toolbarHelper.setLayoutLeft(true, R.drawable.backicon, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //搜索客户信息，优先关闭软键盘
                KeyboardUtils.hideSoftInput(mActivityInstance);
                methodBack();
            }
        });

        toolbarHelper.setLayoutRight(false, 0, "", null);

    }

    @Override
    protected void onClickNodata(View v) {

        //retain

    }

    @Override
    protected void initViews() {

        //监听
        //--------------------------------------------------------
        //如果图片路径不是空，那么需要重新填充
        //图片处理器
        if (mplimageListInArchiveFileEdit != null) {

            mplimageListInArchiveFileEdit.setMaskProgressLayoutListener(new MaskProgressLayoutListener() {

                @Override
                public void onItemAdd(@NonNull View view, @NonNull MultiMediaView multiMediaView, //
                                      int alreadyImageCount,//
                                      int alreadyVideoCount, //
                                      int alreadyAudioCount) {


                    try {

                        // public static final String READ_MEDIA_AUDIO = "android.permission.READ_MEDIA_AUDIO";
//                        public static final String READ_MEDIA_IMAGES = "android.permission.READ_MEDIA_IMAGES";
//                        public static final String READ_MEDIA_VIDEO = "android.permission.READ_MEDIA_VIDEO";

                        //判断版本
                        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {

                            //do
                            //首次添加的添加按钮
                            //添加权限提示，人为的提示；
                            if (!AndPermission.hasPermissions(mActivityInstance, Permission.CAMERA)//
                                    || !AndPermission.hasPermissions(mActivityInstance, Permission.WRITE_EXTERNAL_STORAGE)//
                                    || !AndPermission.hasPermissions(mActivityInstance, Permission.READ_EXTERNAL_STORAGE)) {//

                                CommUtils.checkMaterialDialog(materialDialog);

                                materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_CAMERA_STORAGE, new AuthorityCallbackListener() {
                                    @Override
                                    public void doSomeThing() {

                                        CommUtils.checkMaterialDialog(materialDialog);

                                        //添加访问权限内容
                                        AndPermission.with(ArchiveImageFileTypeActivity.this)
                                                .runtime()//
                                                .permission(Permission.CAMERA,//
                                                        Permission.READ_EXTERNAL_STORAGE, //
                                                        Permission.WRITE_EXTERNAL_STORAGE)//
                                                .rationale(new RuntimeRationale())//
                                                .onGranted(new com.yanzhenjie.permission.Action<List<String>>() {
                                                    @Override
                                                    public void onAction(List<String> permissions) {

                                                        //直接的执行,仅仅拍照+录视频
                                                        openMain(alreadyImageCount, alreadyVideoCount, alreadyAudioCount);

                                                    }
                                                }).onDenied(new com.yanzhenjie.permission.Action<List<String>>() {
                                                    @Override
                                                    public void onAction(List<String> permissions) {

                                                        ToastUtils.showShort(ConstantSign.NEEDPERMISS_PHONE);

                                                        PermissionSetting permissionSetting = new PermissionSetting(mActivityInstance);
                                                        if (AndPermission.hasAlwaysDeniedPermission(ArchiveImageFileTypeActivity.this, permissions)) {
                                                            permissionSetting.showSetting(ConstantApi.PERMISSION_NORMAL, ArchiveImageFileTypeActivity.this, permissions);
                                                        }

                                                    }
                                                }).start();

                                    }
                                });

                            } else {

//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "正常的权限已经打开，可以执行拍照操作");
                                //直接的执行,仅仅拍照+录视频
                                openMain(alreadyImageCount, alreadyVideoCount, alreadyAudioCount);
                            }

                        } else {

                            //do
                            //首次添加的添加按钮
                            //添加权限提示，人为的提示；
                            if (!XXPermissions.isGranted(mActivityInstance, com.hjq.permissions.Permission.CAMERA)//
                                    || !XXPermissions.isGranted(mActivityInstance, com.hjq.permissions.Permission.READ_MEDIA_IMAGES)) {

                                CommUtils.checkMaterialDialog(materialDialog);

                                materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_CAMERA_STORAGE, new AuthorityCallbackListener() {
                                    @Override
                                    public void doSomeThing() {

                                        CommUtils.checkMaterialDialog(materialDialog);

                                        XXPermissions.with(ArchiveImageFileTypeActivity.this)
                                                // 适配分区存储应该这样写
                                                //.permission(Permission.Group.STORAGE)
                                                // 不适配分区存储应该这样写
                                                .permission(com.hjq.permissions.Permission.CAMERA)//
                                                .permission(com.hjq.permissions.Permission.READ_MEDIA_IMAGES)//
//                                                          .permission(com.hjq.permissions.Permission.READ_MEDIA_VIDEO)//
//                                                          .permission(com.hjq.permissions.Permission.READ_MEDIA_AUDIO)//
                                                //).permission(com.hjq.permissions.Permission.MANAGE_EXTERNAL_STORAGE
//                                                        .interceptor(new PermissionInterceptor())
                                                .request(new OnPermissionCallback() {

                                                    @Override
                                                    public void onGranted(@NonNull List<String> permissions, boolean allGranted) {

                                                        if (!allGranted) {
                                                            // TODO: 2024/1/23 18:50 权限这里要不要给提示？权限没通过

                                                            return;
                                                        }

                                                        Toaster.show(String.format(getString(R.string.demo_obtain_permission_success_hint),
                                                                PermissionNameConvert.getPermissionString(ArchiveImageFileTypeActivity.this, permissions)));

                                                        openMain(alreadyImageCount, alreadyVideoCount, alreadyAudioCount);
                                                    }
                                                });


                                    }
                                });

                            } else {

//                               LogUtils.d(ConstantSign.LOGCAT_NOMAL + "正常的权限已经打开，可以执行拍照操作");
                                //直接的执行,仅仅拍照+录视频
                                openMain(alreadyImageCount, alreadyVideoCount, alreadyAudioCount);

                            }

                        }


                    } catch (Exception e) {
                        //catch
                        e.printStackTrace();
                    }


                }

                @Override
                public void onItemClick(@NonNull View view, @NonNull MultiMediaView multiMediaView) {

                    try {
                        //do
                        if (multiMediaView.isImageOrGif() || multiMediaView.isVideo()) {//

                            if (mplimageListInArchiveFileEdit != null) {

                                if (mGlobalSetting != null) {

                                    mGlobalSetting.openPreviewData(ArchiveImageFileTypeActivity.this, REQUEST_CODE_CHOOSE,
                                            mplimageListInArchiveFileEdit.getImagesAndVideos(),//
                                            mplimageListInArchiveFileEdit.getImagesAndVideos().//
                                                    indexOf(multiMediaView));//
                                } else {
                                    ToastUtils.showShort(StringUtils.getString(R.string.globalsettingnull));
                                }
                            }

                        }

                    } catch (Exception e) {
                        //catch
                        e.printStackTrace();
                    }

                }

                @Override
                public void onItemStartUploading(@NonNull MultiMediaView multiMediaView) {

                }

                @Override
                public void onItemClose(@NonNull View view, @NonNull MultiMediaView multiMediaView) {

                    //对图片的编辑；
                    try {
                        //do
                        if (multiMediaView != null) {

                            //是否要区分：是【添加图片】还是【从详情里取到的图片】
                            //filepath有可能是空的，但是
//                            {
//                                    "file_path_server": "null/20230818/2023081816385668841893.jpg",
//                                    "file_url_server": "http://222.222.17.184:8990/resource/null/20230818/2023081816385668841893.jpg"
//                            }

//                            {
//                                    "file_path_local": "/storage/emulated/0/DCIM/Camera/IMG_20230723_084352.jpg",
//                                    "file_name": "IMG_20230723_084352.jpg",
//                                    "file_path_server": "null/20230829/2023082910243621252656_750x750.jpg",
//                                    "file_url_server": "http://222.222.17.184:8990/resource/null/20230829/2023082910243621252656_750x750.jpg",
//                                    "file_upload": {
//                                    "filePath": "null/20230829/2023082910243621252656_750x750.jpg"
//                            }

                            //是从本地 添加的
                            String filePath = multiMediaView.getPath();
                            String file_url_server = multiMediaView.getUrl();

                            if (!TextUtils.isEmpty(filePath)) {

                                //LogUtils.d(ConstantSign.LOGCAT_NOMAL + "---filePath-->" + filePath);
                                //itchen-->---filePath-->/storage/emulated/0/middlelow/IMAGE_20230512_173801068.jpg

                                String getCurrentFileShortName = CommUtils.valueStringSplit(filePath);

                                if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {

                                    //遍历循环装载HashMap的list
                                    Iterator<HashMap<String, Object>> iterator = fileSingleUpLoadFiles_upLoad_hashMap.iterator();

                                    if (iterator != null) {

                                        while (iterator.hasNext()) {

                                            HashMap<String, Object> hashMapItem = iterator.next();

                                            if (hashMapItem != null) {

                                                String file_short_name_local = (String) hashMapItem.get(Parameterkey.file_name);

                                                if (!TextUtils.isEmpty(getCurrentFileShortName) && !TextUtils.isEmpty(file_short_name_local)) {
                                                    if (TextUtils.equals(getCurrentFileShortName, file_short_name_local)) {
                                                        fileSingleUpLoadFiles_upLoad_hashMap.remove(hashMapItem);
                                                        LogUtils.json(ConstantSign.LOGCAT_NOMAL + "即将删除--本地选择或拍照的--本地数据-hashMapItem-->", hashMapItem);
                                                        break;
                                                    }
                                                }

                                            }
                                        }
                                    }
                                }


                            }

                            //---------------------------------------------------------------------------------------------------------------------------
                            //第二次过滤
                            if (!TextUtils.isEmpty(file_url_server)) {

                                String getCurrentFileShortName = CommUtils.valueStringSplit(file_url_server);
                                //getCurrentFileShortName 的取值是要这种短名称效果："file_name": "IMG_20230723_084352.jpg",

                                if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {

                                    //遍历循环装载HashMap的list
                                    Iterator<HashMap<String, Object>> iterator = fileSingleUpLoadFiles_upLoad_hashMap.iterator();

                                    if (iterator != null) {

                                        while (iterator.hasNext()) {

                                            HashMap<String, Object> hashMapItem = iterator.next();

                                            if (hashMapItem != null) {

                                                String file_short_name_local = (String) hashMapItem.get(Parameterkey.file_name);

                                                if (!TextUtils.isEmpty(getCurrentFileShortName) && !TextUtils.isEmpty(file_short_name_local)) {
                                                    if (TextUtils.equals(getCurrentFileShortName, file_short_name_local)) {
                                                        fileSingleUpLoadFiles_upLoad_hashMap.remove(hashMapItem);
                                                        LogUtils.json(ConstantSign.LOGCAT_NOMAL + "即将删除--在线携带的-本地数据-hashMapItem-->", hashMapItem);
                                                        break;
                                                    }
                                                }

                                            }
                                        }
                                    }
                                }
                            }
                            //---------------------------------------------------------------------------------------------------------------------------

                        }

                    } catch (Exception e) {
                        //catch
                        e.printStackTrace();
                    }

                }

                @Override
                public void onItemAudioStartDownload(@NonNull View view, @NonNull String s) {

                }

                @Override
                public boolean onItemVideoStartDownload(@NonNull View view, @NonNull MultiMediaView multiMediaView) {
                    return false;
                }

                @Override
                public void onAddDataSuccess(@NonNull List<MultiMediaView> list) {

//                    for (MultiMediaView multiMediaView :
//                            list) {
//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "multiMediaView.getPath()--->" + multiMediaView.getPath());
//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "----------------------multiMediaView.getUrl()------------------->" + multiMediaView.getUrl());
//
//                    }


                }
            });

            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "文件的长度-->" + extra_accessorysForAppUrlList.size());

            //设置完毕再填充，不然没有初始化完毕，就填充 是错的
            mplimageListInArchiveFileEdit.setImageUrls(extra_accessorysForAppUrlList);

        }

    }

    /**
     * 公共的打开多媒体事件
     *
     * @param alreadyImageCount 已经存在的图片
     * @param alreadyVideoCount 已经存在的语音
     * @param alreadyAudioCount 已经存在的视频
     */
    private void openMain(int alreadyImageCount, int alreadyVideoCount, int alreadyAudioCount) {

        // 拍摄有关设置
        CameraSetting cameraSetting = new CameraSetting();
        // 支持的类型：图片，视频
        //cameraSetting.mimeTypeSet(MimeType.ofAll());
        cameraSetting.mimeTypeSet(MimeType.ofImage());

        // 相册
        AlbumSetting albumSetting = new AlbumSetting(false)
                // 支持的类型：图片，视频
                .mimeTypeSet(MimeType.ofImage())
                // 是否显示多选图片的数字
                .countable(true)
                // 自定义过滤器
                .addFilter(new GifSizeFilter(320, 320, 5 * BaseFilter.K * BaseFilter.K))
                // 开启原图
                .originalEnable(true)
                // 最大原图size,仅当originalEnable为true的时候才有效
                .maxOriginalSize(ConstantApi.MAX_IMAGE_SELECTABLE);

        // 录音机
        //RecorderSetting recorderSetting = new RecorderSetting();

        // 全局
        mGlobalSetting = MultiMediaSetting.from(ArchiveImageFileTypeActivity.this).choose(MimeType.ofImage());
        mGlobalSetting.albumSetting(albumSetting);

//        if (mBinding.cbAlbum.isChecked()) {
//            // 开启相册功能
//            mGlobalSetting.albumSetting(albumSetting);
//        }

        // 开启拍摄功能
        mGlobalSetting.cameraSetting(cameraSetting);

//        if (mBinding.cbRecorder.isChecked()) {
//            // 开启录音功能
//            mGlobalSetting.recorderSetting(recorderSetting);
//        }

        mGlobalSetting
                // 设置路径和7.0保护路径等等
                .allStrategy(new SaveStrategy(true,//
                        ConstantSign.FILE_PROVIDER, //fileProvider
                        ConstantSign.FOLDER_MIDDLELOW))//
                // for glide-V4
                .imageEngine(new Glide4Engine())
                .isImageEdit(false)//禁止编辑图片
                // 最大5张图片、最大3个视频、最大1个音频
                .maxSelectablePerMediaType(null,
                        ConstantApi.MAX_IMAGE_SELECTABLE,//整体设置；
                        ConstantApi.MAX_VIDEO_SELECTABLE,
                        ConstantApi.MAX_AUDIO_SELECTABLE,
                        alreadyImageCount,
                        alreadyVideoCount,
                        alreadyAudioCount)
                .forResult(REQUEST_CODE_CHOOSE);
    }

    @Override
    protected void gainDatas() {

        //这里是携带,还是重新填充？


    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode != RESULT_OK) {
            return;
        }

        if (requestCode == REQUEST_CODE_CHOOSE) {

            // 如果是在预览界面点击了确定
            if (data.getBooleanExtra(BasePreviewActivity.EXTRA_RESULT_APPLY, false)) {

                // 获取选择的数据
                ArrayList<MultiMedia> selected = MultiMediaSetting.obtainMultiMediaResult(data);

//                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "--selected--的值内容-->" + selected);

                if (selected == null) {
                    return;
                }

                // 循环判断，如果不存在，则删除
                if (mplimageListInArchiveFileEdit != null) {
                    for (int i = mplimageListInArchiveFileEdit.getImagesAndVideos().size() - 1; i >= 0; i--) {

                        int k = 0;

                        for (MultiMedia multiMedia : selected) {
                            if (!mplimageListInArchiveFileEdit.getImagesAndVideos().get(i).equals(multiMedia)) {
                                k++;
                            }
                        }

                        if (k == selected.size()) {
                            // 所有都不符合，则删除
                            mplimageListInArchiveFileEdit.removePosition(i);
                        }

                    }
                }

            } else {

                List<LocalFile> result = MultiMediaSetting.obtainLocalFileResult(data);

                ArrayList<String> listUpLoad = new ArrayList<>();


                for (LocalFile localFile : result) {

                    // 绝对路径,AndroidQ如果存在不属于自己App下面的文件夹则无效
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult id:" + localFile.getId());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 绝对路径:" + localFile.getPath());
                    ///storage/emulated/0/middlelow/IMAGE_20230404_155336703.jpg
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 旧图路径:" + localFile.getOldPath());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 原图路径:" + localFile.getOriginalPath());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult Uri:" + localFile.getUri());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 旧图Uri:" + localFile.getOldUri());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 原图Uri:" + localFile.getOriginalUri());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 文件大小: " + localFile.getSize());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 视频音频长度: " + localFile.getDuration());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 是否选择了原图: " + localFile.isOriginal());

//                    if (localFile.isImageOrGif()) {
//                        if (localFile.isImage()) {
//                            LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 图片类型");
//                        } else if (localFile.isImage()) {
//                            LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 图片类型");
//                        }
//                    } else if (localFile.isVideo()) {
//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 视频类型");
//                    } else if (localFile.isAudio()) {
//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 音频类型");
//                    }
//
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 具体类型:" + localFile.getMimeType());

                    // 某些手机拍摄没有自带宽高，那么我们可以自己获取
//                    if (localFile.getWidth() == 0 && localFile.isVideo()) {
//
//                        MediaExtraInfo mediaExtraInfo = MediaUtils.getVideoSize(getApplication(), localFile.getPath());
//                        localFile.setWidth(mediaExtraInfo.getWidth());
//                        localFile.setHeight(mediaExtraInfo.getHeight());
//                        localFile.setDuration(mediaExtraInfo.getDuration());
//
//                    }
//
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 宽高: " + localFile.getWidth() + "x" + localFile.getHeight());

                    //method_single_image_addSubmit_upLoad(localFile.getPath());

                    if (!TextUtils.isEmpty(localFile.getPath())) {
                        listUpLoad.add(localFile.getPath());
                    }

//                    //这里不能直接存储--因为此处为 图片单个上传：直接 存储
//                    HashMap<String, Object> hashMapTemp = new HashMap<String, Object>();
//                    hashMapTemp.put(Parameterkey.file_name, CommUtils.valueStringSplit(localFile.getPath()));
//                    hashMapTemp.put(Parameterkey.file_path_local, localFile.getPath());
//
//                    if (fileSingleUpLoadFiles_upLoad_hashMap != null) {
//                        fileSingleUpLoadFiles_upLoad_hashMap.add(hashMapTemp);
//                    }

                }

                //------------------------------------------------------------------------------------------------------------------------------------
                //LogUtils.d(ConstantSign.LOGCAT_NOMAL, "执行了--addLocalFileStartUpload---addLocalFileStartUpload---addLocalFileStartUpload");
                if (mplimageListInArchiveFileEdit != null) {
                    mplimageListInArchiveFileEdit.addLocalFileStartUpload(result);
                }
                //------------------------------------------------------------------------------------------------------------------------------------

                //添加上传的内容的，间隔500毫秒上传一个；
                //数据的对象
                Observable<String> dataA = Observable.fromIterable(listUpLoad).subscribeOn(AndroidSchedulers.mainThread());
                //时间的对象,给N秒时间，因为要处理 3 个接口
                Observable<Long> timeB = Observable.interval(ConstantApi.UPLOAD_TIME_INTERVAL, TimeUnit.MILLISECONDS).subscribeOn(AndroidSchedulers.mainThread());
                //合并
                mCompositeDisposable.add(Observable.zip(dataA, timeB, new BiFunction<String, Long, String>() {
                            @Override
                            public String apply(String sValueUpLoadFilter, Long aLong) throws Throwable {
//                                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "转换之后的地址是-->" + sValueUpLoadFilter);
                                return sValueUpLoadFilter;
                            }
                        }).subscribeOn(AndroidSchedulers.mainThread())//
                        .observeOn(AndroidSchedulers.mainThread())//
                        .subscribe(new Consumer<String>() {
                            @Override
                            public void accept(String sValueUpLoad) throws Throwable {

                                method_single_image_addSubmit_upLoad(sValueUpLoad);

                            }
                        }, new Consumer<Throwable>() {
                            @Override
                            public void accept(Throwable throwable) throws Throwable {
                                if (throwable != null) {
                                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "上传单个图片-执行了获取报错--->" + throwable.getMessage());
                                }
                            }
                        }));

            }
        }

    }

    //这里仅仅是修改客户携带的档案信息；
    private void method_remedialItems_addSubmit_upLoad(ArrayList<InformationAccessoryUpLoad> _informationAccessoryList) {

//                ArchiveUpdateType
//                UPDATETYPE_1("1","整体修改"),
//                UPDATETYPE_2("2","只修改客户信息"),
//                UPDATETYPE_3("3","只修改附件"),
//                UPDATETYPE_4("4","只修改合同"),
//                UPDATETYPE_5("5","只修改车辆信息");

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());
//        map.put(Parameterkey.vehicleId, vehicleId_informationId_upLoad);
        //2023年11月9日17:37:21 因为改造客户档案要修改
        map.put(Parameterkey.informationId, vehicleId_informationId_upLoad);
        map.put(Parameterkey.updateType, ArchiveUpdateType.UPDATETYPE_3.getIndex());
        //档案的携带信息；
        map.put(Parameterkey.informationAccessoryList, _informationAccessoryList);//附件内容

//        map.put(Parameterkey.archivesManageList, _archivesManageList);
//        map.put(Parameterkey.informationAccessoryList, _informationAccessoryList);//是否产生费用

//        updateType
//        1: 整体修改 或者传递空值null
//        2: 只修改客户信息
//        3: 只修改附件
//        4: 只修改合同
//        5: 只修改车辆信息

//        {
//            "clientManage":{
//            "clientName":"张三",
//                    "idCard":"13010818890212122435",
//                    "gender":1,
//                    "age":23,
//                    "phone":"151626332333",
//                    "wechatNumber":"Z_s1234",
//                    "email":"Z_s1234@qq.com",
//                    "address":"河北省石家庄裕华区盛邦花园1区",
//                    "companyDetail":"",
//                    "position":"运维",
//        },
//                "vehicleId":6,
//                "vin":"车架号",
//                "licenseNumber":"冀A88888",
//                "vehicleType":"1",
//                "carBranch":"大众",
//                "carModel":"朗逸运动款",
//                "carSeries":"朗逸",
//                "engineNum":"发动机号",
//                "archivesManageList":[],
//            "informationAccessoryList":[
//            {
//                "filePath":"http://地址",
//                    "fileName":"文件名称",
//                    "fileSize":1023
//            }
//    ]
//        }

//----如下是完整的提交信息-----------------------------------------------------------------------------------------
//        {
//            "archivesManageList":[
//            {
//                "amount":"250000",
//                    "archiveNo":"",
//                    "archiveTypeId":"1",
//                    "archivesManageFileVoList":[
//                {
//                    "filePath":"null/20230818/2023081816384755133904_750x750.png"
//                },
//                {
//                    "filePath":"null/20230818/2023081816384897186872_750x750.png"
//                },
//                {
//                    "filePath":"null/20230818/2023081816385102644935_750x750.png"
//                }
//			],
//                "brandModel":"",
//                    "carBrand":"",
//                    "partyA":"陈大",
//                    "signingDate":"2023-08-30"
//            }
//	],
//            "carBranch":"8",
//                "carModel":"小轿车",
//                "carSeries":"149",
//                "clientManage":{
//            "address":"天同街",
//                    "age":"36",
//                    "clientName":"陈琪",
//                    "companyDetail":"盛邦乡村数科",
//                    "email":"chenqi@163.com",
//                    "gender":"0",
//                    "idCard":"",
//                    "phone":"17531108969",
//                    "position":"测试程序员",
//                    "wechatNumber":"18810042043"
//        },
//            "engineNum":"25486687785",
//                "informationAccessoryList":[
//            {
//                "fileName":"null/20230818/2023081816385624239559.jpg",
//                    "filePath":"http://222.222.17.184:8990/resource/null/20230818/2023081816385624239559.jpg",
//                    "fileSize":""
//            },
//            {
//                "fileName":"null/20230818/2023081816385648633083.jpg",
//                    "filePath":"http://222.222.17.184:8990/resource/null/20230818/2023081816385648633083.jpg",
//                    "fileSize":""
//            },
//            {
//                "fileName":"null/20230818/2023081816385668841893.jpg",
//                    "filePath":"http://222.222.17.184:8990/resource/null/20230818/2023081816385668841893.jpg",
//                    "fileSize":""
//            }
//	],
//            "licenseNumber":"浙CS8417",
//                "shopInfoId":"1495",
//                "vehicleType":"1",
//                "vin":"FGHURUGDE"
//        }

        //-----------------------------------------------------------------------------------------

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_UPDATEINFORMATIONMANAGE_INFOIMAGES_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.addInformationManage_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        //上传的json内容是
        String jsonObject_UpLoad = JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue);
//        LogUtils.d(ConstantSign.LOGCAT_NOMAL, jsonObject_UpLoad);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .updateInformationManage(RequestBody.create(jsonObject_UpLoad, MediaType.parse(ApiService.HEADER_JSON)))
                .compose(ArchiveImageFileTypeActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<String>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        CommUtils.checkMaterialDialog(materialDialog);

                        if (!TextUtils.isEmpty(serverMessage)) {
                            ToastUtils.showShort(serverMessage);
                        }

                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {
                        method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_SUBMIT);
                    }
                }).subscribe(new Consumer<String>() {
                    @Override
                    public void accept(String stringValue) throws Throwable {

                        CommUtils.checkMaterialDialog(materialDialog);

                        //TipDialog.show(StringUtils.getString(R.string.add_submit_success), WaitDialog.TYPE.SUCCESS);

                        //直接刷新档案详情-因为图片变动；
                        EventArchiveDetail eventArchiveDetail = new EventArchiveDetail();
                        eventArchiveDetail.setMessage(ExtraValue.EVENTBUS_EVENT_TO_REFRESH_ARCHIVEFILE_DETAIL);
                        EventBus.getDefault().post(eventArchiveDetail);

                        methodSubmitSuccess(ArchiveImageFileTypeActivity.this, new DoSomeThingListener() {
                            @Override
                            public void doSomeThing() {
                                //页面关闭直接回到档案管理主页列表页面
                                methodBack();
                            }
                        });

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {

                    }
                });

    }


    private void method_single_image_addSubmit_upLoad(String _filePathLocal) {

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.file, _filePathLocal);//

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_UPLOADACCESSORY_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.uploadAccessory_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        //上传的是文件：
        MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder()//
                .setType(MultipartBody.FORM);//

        File filUpLoad = new File(_filePathLocal);

        if (filUpLoad != null) {
            //是单个的文件，只需要添加一个即可
            multipartBodyBuilder.addFormDataPart(Parameterkey.imageFile, filUpLoad.getName(),//
                    RequestBody.create(filUpLoad, MediaType.parse(ApiService.MEDIATYPE_IMAGE_JPG)));//
        }

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                //.uploadSingle(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue), MediaType.parse(ApiService.HEADER_JSON)))
                .uploadAccessory(multipartBodyBuilder.build())
                .compose(ArchiveImageFileTypeActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<FileSingleUpLoadBean>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {

//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "添加上传图片的接口-------响应的-------->_filePathLocal-->" + _filePathLocal);
//                        int percentage = 0;// 百分比
//                        if (_multiMediaView != null) {
//                            //percentage
//                        }

                    }
                }).subscribe(new Consumer<FileSingleUpLoadBean>() {
                    @Override
                    public void accept(FileSingleUpLoadBean fileSingleUpLoadBean) throws Throwable {

//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "添加上传图片的接口--响应的数据-->" + fileSingleUpLoadBean.getFileName());

                        if (fileSingleUpLoadBean != null) {

                            // : 2023-04-04 填充真实的图片的路径和name
                            FileUpLoad fileUpLoad = new FileUpLoad();
                            fileUpLoad.setFilePath(fileSingleUpLoadBean.getUrlSuffix());
//                            fileUpLoadManageCheckRecord.setFileName(fileSingleUpLoadBean.getFileName().substring(//
//                            fileSingleUpLoadBean.getFileName().lastIndexOf("/") + 1));

                            //直接 存储
                            HashMap<String, Object> hashMapTemp = new HashMap<String, Object>();
                            hashMapTemp.put(Parameterkey.file_name, CommUtils.valueStringSplit(_filePathLocal));
                            hashMapTemp.put(Parameterkey.file_path_local, _filePathLocal);
                            hashMapTemp.put(Parameterkey.file_path_server, fileSingleUpLoadBean.getUrlSuffix());
                            hashMapTemp.put(Parameterkey.file_url_server, fileSingleUpLoadBean.getUrl());
                            hashMapTemp.put(Parameterkey.file_upload, fileUpLoad);
                            //这里带的是携带过来的
                            if (extra_ArchivesManageFileMy != null) {
                                hashMapTemp.put(Parameterkey.file_file_type, extra_ArchivesManageFileMy.getFileType());//当前正在操作的类型
                                hashMapTemp.put(Parameterkey.file_file_type_name, extra_ArchivesManageFileMy.getFileTypeName());//当前正在操作的类型的名称和标题
//                              hashMapTemp.put(Parameterkey.file_required, fileSingleUpLoadBean.isRequired());//当前附件是否必传
                            }

                            if (fileSingleUpLoadFiles_upLoad_hashMap != null) {
                                fileSingleUpLoadFiles_upLoad_hashMap.add(hashMapTemp);
                            }

                            method_test_upLoadHashMapCurentChange();

                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {

                        //图片上传失败；
                        if (apiException != null) {
                            if (!TextUtils.isEmpty(apiException.getDisplayMessage())) {
                                ToastUtils.showShort(apiException.getDisplayMessage());
                            }
                        }

                    }
                });


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        vehicleId_informationId_upLoad = "";

        if (mGlobalSetting != null) {
            mGlobalSetting.onDestroy();
        }

        if (mplimageListInArchiveFileEdit != null) {
            mplimageListInArchiveFileEdit.onDestroy();
        }

        if (extra_accessorysForAppUrlList != null) {
            extra_accessorysForAppUrlList.clear();
            extra_accessorysForAppUrlList = null;
        }

        if (fileSingleUpLoadFiles_upLoad_hashMap != null) {
            fileSingleUpLoadFiles_upLoad_hashMap.clear();
            fileSingleUpLoadFiles_upLoad_hashMap = null;
        }

    }

    @Override
    protected void methodBack() {

        methodBackFinish();

    }

    @Override
    public void processExtraData() {

        if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {
            fileSingleUpLoadFiles_upLoad_hashMap.clear();
        }

        if (extra_accessorysForAppUrlList != null && !extra_accessorysForAppUrlList.isEmpty()) {
            extra_accessorysForAppUrlList.clear();
        }

        //携带 图片链接信息
        Bundle extras_bundle = this.getIntent().getExtras();

        if (extras_bundle != null) {

            //flag_jumpfrom_where_type = extras_bundle.getString(ExtraKey.EXTRA_JUMPFROM_WHERE_TYPE);

            extra_archivesManageFileType = extras_bundle.getInt(ExtraKey.EXTRA_ARCHIVESMANAGE_FILETYPE);
            extra_InformationManageVo_extra = extras_bundle.getParcelable(ExtraKey.EXTRA_INFORMATION_MANAGE_VO_EXTRA);
            extra_ArchivesManageFileMy = extras_bundle.getParcelable(ExtraKey.EXTRA_ARCHIVES_MANAGEFILE_MY);

            //打印携带的日志内容：
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "extra_archivesManageFileType-->当前即将编辑的类型是->" + extra_archivesManageFileType);
            LogUtils.json(ConstantSign.LOGCAT_NOMAL + "查看携带的内容--extra_InformationManageVo_extra-->", extra_InformationManageVo_extra);

            if (extra_InformationManageVo_extra != null) {

                //车辆档案id
//              vehicleId_upLoad = extra_InformationManageVo_extra.getVehicleId();
                vehicleId_informationId_upLoad = extra_InformationManageVo_extra.getInformationId();

                //携带档案附件的实体
                ArrayList<InformationAccessoryUpLoad> informationAccessoryList_inside = extra_InformationManageVo_extra.getInformationAccessoryList();
                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "informationAccessoryList_inside-->长度是->" + informationAccessoryList_inside.size());

                if (informationAccessoryList_inside != null && !informationAccessoryList_inside.isEmpty()) {

                    for (InformationAccessoryUpLoad informationAccessoryUpLoad_item : informationAccessoryList_inside) {

                        String filePath_short_half = informationAccessoryUpLoad_item.getFilePath();
                        String file_url_server = informationAccessoryUpLoad_item.getUrl();
                        //存储fileName = ; 为了删除用
                        //文件类型
                        int fileType = informationAccessoryUpLoad_item.getFileType();
                        //filetypename
                        String fileTypeName = informationAccessoryUpLoad_item.getFileTypeName();

                        if (fileType == extra_archivesManageFileType) {
                            //过滤掉当前需要编辑的类型，只保存历史的其他的类型的逻辑

                        } else {

                            //首先赋值给 hashMap
                            HashMap<String, Object> hashMap = new HashMap<>();
                            if (!TextUtils.isEmpty(filePath_short_half)) {
                                hashMap.put(Parameterkey.file_path_server, filePath_short_half);
                            }

                            if (!TextUtils.isEmpty(file_url_server)) {
                                hashMap.put(Parameterkey.file_url_server, file_url_server);

                                String fileName = CommUtils.valueStringSplit(file_url_server);
                                if (!TextUtils.isEmpty(fileName)) {
                                    hashMap.put(Parameterkey.file_name, fileName);
                                    //形式如："2023081816385648633083.jpg"
                                }

                            }

                            //文件的类型 2024-2-26 11:47:02新增
                            hashMap.put(Parameterkey.file_file_type, fileType);

                            //2024-2-26 11:45:31新增文件类型的名称
                            if (!TextUtils.isEmpty(fileTypeName)) {
                                hashMap.put(Parameterkey.file_file_type_name, fileTypeName);
                            }

                            if (fileSingleUpLoadFiles_upLoad_hashMap_history != null) {
                                fileSingleUpLoadFiles_upLoad_hashMap_history.add(hashMap);
                            }
                        }

                    }

                    method_test_upLoadHashMap_history();

                }

            }

            //如果动态附件的逻辑不是空
            if (extra_ArchivesManageFileMy != null) {

                LogUtils.json(ConstantSign.LOGCAT_NOMAL + "查看携带的内容--extra_ArchivesManageFileMy-->", extra_ArchivesManageFileMy);

                //图片链接：只有单个的图片链接：目的为了填充九宫格
                //档案附件类型的类型标志
                int fileType = extra_ArchivesManageFileMy.getFileType();
                //档案附件类型的名称
                String fileTypeName = extra_ArchivesManageFileMy.getFileTypeName();
                //档案附件的所有附件图片，单图片
                ArrayList<ArchivesManageImage> archivesManageImage_inside = extra_ArchivesManageFileMy.getImages();
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "informationAccessoryList_inside-->长度是->" + informationAccessoryList_inside.size());

                if (archivesManageImage_inside != null && !archivesManageImage_inside.isEmpty()) {

                    //上传接口用到的
//                    "informationAccessoryList": [
//                    {
//                        "filePath": "file/information/accessory/20231104/2023110417282178499981.jpeg"
//                    }
//	                  ],

                    for (ArchivesManageImage archivesManageImage : archivesManageImage_inside) {

                        //半截的路径-这才是真正接口上传需要的
                        String filePath_short_half = archivesManageImage.getFilePath();
                        //全路径
                        String file_url_server = archivesManageImage.getFileName();
                        //文件类型
//                        int fileTypeInside = fileType;
                        //filetypename
//                        String fileTypeNameInside = fileTypeName;

                        if (extra_accessorysForAppUrlList != null) {
                            extra_accessorysForAppUrlList.add(file_url_server);
                        }

                        //首先赋值给 hashMap
                        HashMap<String, Object> hashMap = new HashMap<>();
                        if (!TextUtils.isEmpty(filePath_short_half)) {
                            hashMap.put(Parameterkey.file_path_server, filePath_short_half);
                        }

                        if (!TextUtils.isEmpty(file_url_server)) {

                            hashMap.put(Parameterkey.file_url_server, file_url_server);

                            String fileName = CommUtils.valueStringSplit(file_url_server);

                            if (!TextUtils.isEmpty(fileName)) {
                                hashMap.put(Parameterkey.file_name, fileName);
                                //形式如："2023081816385648633083.jpg"
                            }

                        }

                        //文件的类型 2024-2-26 11:47:02 新增
                        hashMap.put(Parameterkey.file_file_type, fileType);

                        //2024-2-26 11:45:31新增文件类型的名称
                        if (!TextUtils.isEmpty(fileTypeName)) {
                            hashMap.put(Parameterkey.file_file_type_name, fileTypeName);
                        }

                        if (fileSingleUpLoadFiles_upLoad_hashMap != null) {
                            fileSingleUpLoadFiles_upLoad_hashMap.add(hashMap);
                        }

                    }

                    method_test_upLoadHashMapCurentChange();

                }

            }
        }
    }

    //列表 条目之中的对象；
    private void method_test_upLoadHashMapCurentChange() {

        //startTime 为了标识是哪个对象的图片;
        if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {

            for (HashMap<String, Object> hashMapItem : fileSingleUpLoadFiles_upLoad_hashMap) {
                LogUtils.json(ConstantSign.LOGCAT_NOMAL + "hashMap 对象 内部上传 ->", hashMapItem);
            }

        }

    }

    //列表之中除了当前改造的这种类型的之外的其他类型的原始记录，只能做当前的保存，不能修改的
    private void method_test_upLoadHashMap_history() {

        //startTime 为了标识是哪个对象的图片;
        if (fileSingleUpLoadFiles_upLoad_hashMap_history != null && !fileSingleUpLoadFiles_upLoad_hashMap_history.isEmpty()) {

            for (HashMap<String, Object> hashMapItemHistory : fileSingleUpLoadFiles_upLoad_hashMap_history) {
                LogUtils.json(ConstantSign.LOGCAT_NOMAL + "hashMap 对象 携带其他类型的历史记录 ->", hashMapItemHistory);
            }

        }

    }

    //当前的文件 和历史记录的附件文件通用的填充方法.
    private void method_fill_hashMap_for_upLoad(ArrayList<HashMap<String, Object>> _fileSingleUpLoadFiles_upLoad_hashMap_fill, ArrayList<InformationAccessoryUpLoad> _informationAccessoryList_UpLoad) {

        if (_fileSingleUpLoadFiles_upLoad_hashMap_fill != null && !_fileSingleUpLoadFiles_upLoad_hashMap_fill.isEmpty()) {

            for (HashMap<String, Object> hashMapItem : _fileSingleUpLoadFiles_upLoad_hashMap_fill) {


//                            {
//                                    "code":"20000",
//                                    "data":{
//                                        "largeUrlSuffix":"",
//                                        "smallUrlSuffix":"",
//                                        "url":"http://222.222.17.184:8990/resource/null/20230818/2023081810312051410204.jpg",
//                                        "urlPrefix":"http://222.222.17.184:8990/resource/",
//                                        "urlSuffix":"null/20230818/2023081810312051410204.jpg"
//                            },

//                            {
//                                    "file_path_local": "/storage/emulated/0/Huawei/MagazineUnlock/magazine-unlock-03-2.3.2023080309-33C2E77690711BF6E81AD3991BB41316.jpg",
//                                    "file_name": "magazine-unlock-03-2.3.2023080309-33C2E77690711BF6E81AD3991BB41316.jpg",
//                                    "file_path_server": "null/20230818/2023081816085441691303.jpg",
//                                    "file_url_server": "http://222.222.17.184:8990/resource/null/20230818/2023081816085441691303.jpg",
//                                    "file_upload": {
//                                    "filePath": "null/20230818/2023081816085441691303.jpg"
//                            }


                InformationAccessoryUpLoad informationAccessory_upLoad_history = new InformationAccessoryUpLoad();

                if (hashMapItem != null) {
                    //完整的携带http的路径
                    // "url":"http://222.222.17.184:8990/resource/null/20230818/2023081810312051410204.jpg",
                    String fileFullPath = (String) hashMapItem.get(Parameterkey.file_url_server);
                    //指定为"urlSuffix":"null/20230818/2023081810312051410204.jpg"
                    String filePath = (String) hashMapItem.get(Parameterkey.file_path_server);
                    //携带附件的类型
                    //图片的附件动态上传类型：2024-2-23 10:18:28
                    int fileType = (int) hashMapItem.get(Parameterkey.file_file_type);
                    //图片附件的动态上传
                    String fileTypeName = (String) hashMapItem.get(Parameterkey.file_file_type_name);

                    informationAccessory_upLoad_history.setFileType(fileType);//2024-2-23 10:28:27新增 附件上传的附件类型。
                    informationAccessory_upLoad_history.setFileTypeName(fileTypeName);//2024-2-23 11:09:39添加附件上传的名称，手机端传递过去，后台可以不用

                    informationAccessory_upLoad_history.setFilePath(filePath);
                    informationAccessory_upLoad_history.setFileName(fileFullPath);
                    informationAccessory_upLoad_history.setFileSize("");
                }

                _informationAccessoryList_UpLoad.add(informationAccessory_upLoad_history);

            }

        }

    }

}